<template>
  <div>
    <ul>
      <li :style="{ opacity }">欢迎学习Vue</li>
      <li v-for="msg in listMsg" :key="msg.id">
        {{ msg.id }} -{{ msg.title }} <input type="text" />
      </li>
    </ul>
    <div>
      <RouterView></RouterView>
    </div>
  </div>
</template>
<script lang="js">
import { RouterView } from "vue-router";

export default {
  name: "News",
  data() {
    return {
      opacity: 1,
      listMsg: [
        { id: "001", title: "路飞" },
        { id: "002", title: "娜美" },
        { id: "003", title: "索龙" },
      ],
    };
  },
  activated() {
    console.log("News组件被激活了");
    this.timer = setInterval(() => {
      console.log("@");
      this.opacity -= 0.01;
      if (this.opacity <= 0) this.opacity = 1;
    }, 32);
  },
  deactivated() {
    console.log("News组件失活了");
    clearInterval(this.timer);
  },
};
</script>
